﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ABCComputer.BLL;
using DTO;

namespace ABCComputer
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        private SanPhamBLL spBLL;
        private SanPhamFullDTO spF;
        private List<SanPhamFullDTO> lstSPF;
        protected void Page_Load(object sender, EventArgs e)
        {
            spBLL = new SanPhamBLL();
            spF = new SanPhamFullDTO();
            lstSPF = new List<SanPhamFullDTO>();
            loadSanPhamLenDataList();
        }

        public void loadSanPhamLenDataList()
        {
            string masanpham = Request.QueryString["masp"];
            lstSPF = spBLL.getSanPhamFull(masanpham);
            DTLChiTietSanPham.DataSource = lstSPF;
            DTLChiTietSanPham.DataBind();

            loadHinhLenDataList(lstSPF, DTLChiTietSanPham);
        }

        // load hinh len datalist
        public void loadHinhLenDataList(List<SanPhamFullDTO> lstSPF , DataList dtl)
        {
            string tenHinh = lstSPF[0].LstHinhAnh[0].TenHinhAnh;
            Image img = (Image)dtl.Items[0].FindControl("imgHinhSP");
            img.ImageUrl = tenHinh;
        }
    }
}